#include <stdio.h>
#include <stdlib.h>
struct time
{
    int hour;
    int minute;
    int second;
};
int input_time(struct time *t);
int add_time(struct time *t, int s);

int main()
{
    struct time t;
    int s;
    if(input_time(&t))
    {
        exit(0);
    }
    printf("time is : %d:%d:%d\n",t.hour,t.minute,t.second);
    printf("please input n seconds:");
    scanf("%d",&s);
    if(!add_time(&t,s))
    {
        printf("new time is : %d:%d:%d\n",t.hour,t.minute,t.second);
    }
    return 0;
}

int input_time(struct time *t)
{
    int h,m,s;

    printf("please input a time:H:M:S,");
    scanf("%d : %d : %d",&h,&m,&s);
    if(m<0 || m>60)
    {
        printf("分钟应为0=<m<60\n");
        return 1;
    }
    if(s<0 || s>60)
    {
        printf("秒应为0=<s<60\n");
        return 1;
    }
    if(h<0 || h>24)
    {
        printf("小时应为0=<h<24\n");
        return 1;
    }
    t->hour = h;
    t->minute = m;
    t->second = s;
    return 0;

}

int add_time(struct time *t, int s)
{
    int x,y,z;
    x = (t->second + s) / 60;
    t->second = (t->second + s) % 60;
    y = (t->minute + x ) / 60;
    t->minute = (t->minute + x ) % 60;
    t->hour = (t->hour + y) % 24;
}